package cn.amebius.simpledocker.controller.request;

import cn.amebius.simpledocker.exception.ParameterErrorException;
import cn.hutool.core.date.DateTime;
import lombok.Data;


/**
 * 添加用户的接口
 * @author 阿伟
 * @date 2023/8/3 15:56
 */

@Data
public class AddUserRequest {

    private String username;

    private String password;

    private String name;

    private String email;

    private String mobile;

    private Integer groupId;

    private Integer roleId;
    
    public void checkParameter() {
        if (username.isEmpty() || password.isEmpty() || name.isEmpty() || email.isEmpty() || mobile.isEmpty() || groupId.toString().isEmpty() || roleId.toString().isEmpty()) {
            throw new ParameterErrorException("参数未未填写");
        } else if (username.length() >= 40 || password.length() >= 40){
            throw new ParameterErrorException("账号或密码太长");
        } else if (username.length() < 8 || password.length() < 8) {
            throw new ParameterErrorException("账号或密码太短");
        } else if (mobile.length() != 11) {
            throw new ParameterErrorException("手机号长度错误");
        }
    }
}
